<?php
class Les
{ 
  public $day;
  public $week;
  public $year;
  public $time;
  public $weekday;
  
  function __construct($day, $week, $year, $time, $weekday)
  {
    $this->day     = $day;
    $this->week    = $week;
    $this->year    = $year;
    $this->time    = $time;
    $this->weekday = $weekday;
  }

  public static function get_max_deelnemers()
  {
    return 13; 
  }

  public static function lesweken($day, $time)
  {
    $query = mysql_query('SELECT DISTINCT '.DB_LES.'.week FROM leden INNER JOIN '.DB_DEELNEMER.' INNER JOIN '.DB_LES.' ON ('.DB_DEELNEMER.'.les_ID = '.DB_LES.'.ID AND '.DB_DEELNEMER.'.user_ID = leden.ID) WHERE '.DB_LES.'.dag_naam="'.$day.'" AND '.DB_LES.'.tijd="'.$time.'"');
    
    while ($row = mysql_fetch_assoc($query))
      $weeks[] = $row['week'];

    return $weeks;
  }

  public static function get_id($day, $week, $year, $time)
  {
    $query = mysql_query('SELECT ID FROM '.DB_LES.' WHERE dag="'.$day.'" AND week="'.$week.'" AND jaar="'.$year.'" AND tijd="'.$time.'" LIMIT 1');
    $row   = mysql_fetch_assoc($query);

    if (empty($row))
      return -1;

    return $row['ID'];
  }

  public static function by_id($id)
  {
    $query = mysql_query('SELECT * FROM '.DB_LES.' WHERE ID="'.$id.'" LIMIT 1');
    $row   = mysql_fetch_assoc($query);

    if (! empty($row))
      return new Les($row['dag'], $row['week'], $row['jaar'], $row['tijd'], $row['dag_naam']);
  }
}
?>